package com.student.Activitys.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.student.Activitys.R;
import com.student.Activitys.adapter.base.BaseRecyleViewAdapter;
import com.student.Activitys.adapter.viewholder.CollegeSurveyViewHolder;
import com.student.Activitys.bean.CollegeSurveyBean;
import com.student.Activitys.utils.FrescoUtils;

import java.util.List;

/**
 * 项目名称：智慧校园学生端
 * 类描述：学院概况 adapter
 * 创建人：张飞祥
 * 创建时间：2017/10/31 11:17
 * 修改人：张飞祥
 * 修改时间：2017/10/31 11:17
 * 修改备注：
 */
public class CollegeSurveyAdapter extends BaseRecyleViewAdapter {


    //上下文
    private Context context;
    //数据集合
    private List<CollegeSurveyBean> list;

    public CollegeSurveyAdapter(Context context, List<CollegeSurveyBean> list) {
        super(context, list);
        this.context = context;
        this.list = list;
    }

    @Override
    protected int getLayoutItmeResId() {
        return R.layout.item_college_survey;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof CollegeSurveyViewHolder) {
            CollegeSurveyViewHolder viewHolder = (CollegeSurveyViewHolder) holder;
            //将数据保存在itemView的Tag中，以便点击时进行获取
            viewHolder.itemView.setTag(position);
            //加载图标
            FrescoUtils.loadImage(list.get(position).getPic_url(),viewHolder.svItemSurveyIcon);
            //加载标题
            viewHolder.tvItemSurveyTitle.setText(list.get(position).getTitle());
        }
    }

    @Override
    public RecyclerView.ViewHolder getViewHolder(View view) {
        return new CollegeSurveyViewHolder(view);
    }
}
